#include "widget.h"
#include "ui_widget.h"

#include <QDateTime>
#include <QTimer>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    QTimer* time = new QTimer(this);

    connect(ui->pushButton_start, &QPushButton::clicked, [=](){
        time->start(1000);
    });
    connect(ui->pushButton_stop, &QPushButton::clicked, [=](){
        time->stop();
    });

    connect(time, &QTimer::timeout, this, &Widget::TimeUpDate);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::TimeUpDate()
{
    QString str = QDateTime::currentDateTime().toString("yyyy-MM-dd hh::mm::ss");
    ui->label->setText(str);
}

